import axios from 'axios'
import store from '@/store'
import { Toast } from 'vant';
axios.interceptors.request.use(function(config) {
    Toast.loading({
        forbidClick: true,
        message: '加载中...'
    });
    var token = store.state.token;
    if (token) {
        config.headers.Authorization = 'Bearer' + token;
    }
    return config;
}, function(error) {
    return Promise.reject(error)
});
axios.interceptors.response.use(function(res) {
    Toast.clear();
    return res;
}, function(error) {
    Toast.clear();
    return error;
});

export default axios;